import Base from './base.js';
import fs from 'fs'
import path from 'path';
const rename = think.promisify(fs.rename, fs); 
export default class extends Base {
      $verify_login = false;
      async indexAction() {
            return this.json({
                  name:'asDa368dfg6'
            })
      }
      

      async upLoadAction() {
            console.log(this.post());
            
            const file = this.file('file');
            
            if(file && file.type && file.name) {
                  const filepath = path.join(think.ROOT_PATH, 'runtime/upload/'+file.name);
                  console.log(filepath);
                  
                  think.mkdir(path.dirname(filepath));
                  await rename(file.path, filepath)
            }
      }
}
